using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Entities;
using DAL;
using Utility;
namespace BUS
{
    public class tbDoanhNghiepBUS
    {
        public static void Insert_DN(tbDoanhNghiep doanhnghiep)
        {
            tbDoanhNghiepDAL DoanhNghiepDAL = new tbDoanhNghiepDAL();
            DoanhNghiepDAL.Insert(doanhnghiep);
        }
        public static void Update_DN(tbDoanhNghiep doanhnghiep)
        {
            tbDoanhNghiepDAL doanhnghiepDAL = new tbDoanhNghiepDAL();
            doanhnghiepDAL.Update(doanhnghiep);
        }
        public static void Delete_DN(int Id)
        {
            tbDoanhNghiepDAL DoanhNghiepDAL = new tbDoanhNghiepDAL();
            DoanhNghiepDAL.Delete(Id);
        }
        public static tbDoanhNghiepCollection Get(string Where,
            int PageIndex,
            int PageSize,
            string OrderBy,
            string OrderDirection,
            out int TotalRecords)
        {
            tbDoanhNghiepDAL DoanhNghiepDAL = new tbDoanhNghiepDAL();
            return DoanhNghiepDAL.Get(Where, PageIndex, PageSize, OrderBy, OrderDirection, out TotalRecords);
        }
        public static tbDoanhNghiepCollection GetAll()
        {
            Criteria cri = new Criteria();
            int Total = 0;
             tbDoanhNghiepDAL DoanhNghiepDAL = new tbDoanhNghiepDAL();
             return  DoanhNghiepDAL.Get(cri.Criter, 0, 0, tbDoanhNghiepColumns.IdDoanhNghiep.ToString(),
                                OrderDirection.ASC.ToString(), out Total);

        }
        public static tbDoanhNghiep GetById(int Id)
        {
            Criteria cri = new Criteria();
            int Total = 0;
            cri.add(Condition.AND, tbDoanhNghiepColumns.IdDoanhNghiep.ToString(),
                        Condition.EQUAL, Id);
            tbDoanhNghiepDAL DoanhNghiepDAL = new tbDoanhNghiepDAL();
            tbDoanhNghiepCollection DNCollection = DoanhNghiepDAL.Get(cri.Criter, 0, 0,
                                                    tbDoanhNghiepColumns.IdDoanhNghiep.ToString(), 
                                                    OrderDirection.ASC.ToString(), out Total);
            if (DNCollection.Count > 0)
                return DNCollection[0];
            return null;
               
        }

    }
}
